import pandas as pd

from sklearn.naive_bayes import GaussianNB
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

from sklearn import datasets

iris = datasets.load_iris()

# print(iris)
X_train,X_test,Y_train,Y_test = train_test_split(iris.data,iris.target,random_state=12)   #随机种子不一样预测的概率有很大差别

clf = GaussianNB()   #高斯朴素贝叶斯模型
clf.fit(X_train,Y_train)  #fit进行训练

print(clf.predict(X_test) ) #预测结果
print(clf.predict_proba(X_test))  #预测的概率大小，直观的表示出来

print(accuracy_score(Y_test,clf.predict(X_test)))   #输出预测的准确率

